package com.katze.common.data.converters;

import java.math.BigDecimal;

public class LongConverter implements Converter<Long>{

    @Override
    public Long format(Object o) {
        if(o == null || "".equals(o)) {
            return null;
        } else if(o instanceof String){
            return Long.valueOf((String) o);
        }else if(o instanceof Long){
            return (Long) o;
        }else if(o instanceof BigDecimal){
            return ((BigDecimal) o).longValue();
        }else {
            throw new RuntimeException(o.getClass() + "不能转换为java.lang.Integer, 值为[" + o + "]");
        }
    }

}
